package tcpchat;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 创建服务器
 * 写出数据:输出流
 * 读取数据:输入流
 */
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket server=new ServerSocket(8888);
            Socket socket=server.accept();
            //读取数据
            DataInputStream dis=new DataInputStream(socket.getInputStream());
            String msg=dis.readUTF();
            //写出数据
            DataOutputStream dos=new DataOutputStream(socket.getOutputStream());
            dos.writeUTF("服务器--->"+msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
